package xyz.qy.implatform.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import xyz.qy.implatform.dto.RegionGroupMessageDTO;
import xyz.qy.implatform.result.Result;
import xyz.qy.implatform.result.ResultUtils;
import xyz.qy.implatform.service.IRegionGroupMessageService;
import xyz.qy.implatform.vo.RegionGroupMessageVO;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 地区群聊消息
 *
 * @author Polaris
 * @since 2022-11-03
 */
@Api(tags = "地区群聊消息")
@RestController
@RequestMapping("/message/regionGroup")
public class RegionGroupMessageController {

    @Resource
    private IRegionGroupMessageService regionGroupMessageService;

    @PostMapping("/send")
    @ApiOperation(value = "发送群聊消息", notes = "发送群聊消息")
    public Result<RegionGroupMessageVO> sendMessage(@Valid @RequestBody RegionGroupMessageDTO dto) {
        return ResultUtils.success(regionGroupMessageService.sendMessage(dto));
    }

    @GetMapping("/pullOfflineMessage")
    @ApiOperation(value = "拉取消息",notes="拉取消息,一次最多拉取100条")
    public Result<List<RegionGroupMessageVO>> loadMessage(@RequestParam Long minId) {
        regionGroupMessageService.pullOfflineMessage(minId);
        return ResultUtils.success();
    }
}
